import java.util.Stack;

class MinStack {
    Stack<Integer> sk1;
    Stack<Integer> sk2;

    /**
     * initialize your data structure here.
     */
    public MinStack() {

        this.sk1 = new Stack<Integer>();
        this.sk2 = new Stack<Integer>();
    }

    public void push(int x) {
        sk1.push(x);
        if (sk2.isEmpty()) {
            sk2.push(x);
        } else if (x <= sk2.peek()) {
            sk2.push(x);
        }
    }

    public void pop() {
        int tmp = sk1.pop();
        if(!sk2.isEmpty()){
            if(tmp==sk2.peek()){
                sk2.pop();
            }
        }
    }

    @Override
    public String toString() {
        return "MinStack{" +
                "sk1=" + sk1 +
                ", sk2=" + sk2 +
                '}';
    }

    public int top() {
        if (!sk1.isEmpty()) {
            return sk1.peek();
        }
        return -1;

    }

    public int min() {
        if (!sk2.isEmpty()) {
            return sk2.peek();
        }
        return -1;
    }

    public static void main(String[] args) {
        MinStack obj = new MinStack();
        obj.push(-2);
        obj.push(0);
        obj.push(3);
        obj.pop();
        obj.pop();
        obj.pop();
        System.out.println(obj);


    }
}

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack obj = new MinStack();
 * obj.push(x);
 * obj.pop();
 * int param_3 = obj.top();
 * int param_4 = obj.min();
 */